package easy;

import java.util.ArrayList;
import java.util.List;

/*
728. 自除数
解题思路：暴力解法
*/
public class LeeCode728 {


  public List<Integer> selfDividingNumbers(int left, int right) {

    ArrayList<Integer> list = new ArrayList<>();
    
    for (int i = left;i <= right;i++){
      if (isSelf(i)){
        list.add(i);
      }
    }
    return list;

  }
  
  public boolean isSelf(int num){
    for (char c : String.valueOf(num).toCharArray()) {
      if (c =='0' || num % (c - '0') != 0){
        return false;
      }
    }
    return true;
  }

  public static void main(String[] args) {

    List<Integer> list = new LeeCode728().selfDividingNumbers(1, 22);

    System.out.println(list.toString());
  }
}
